'use strict';

module.exports = function(app) {
  var mysqlDs = app.dataSources.mysql;
  var db = app.dataSources.db;

  mysqlDs.autoupdate('ACL', function(err) {
    if (err) throw err;
    console.log('\nAutoupdated table `ACL`.');

    mysqlDs.autoupdate('RoleMapping', function(err) {
      if (err) throw err;
      console.log('\nAutoupdated table `RoleMapping`.');

      mysqlDs.autoupdate('User', function(err) {
        if (err) throw err;
        console.log('\nAutoupdated table `User`.');

        mysqlDs.autoupdate('Role', function(err) {
          if (err) throw err;
          console.log('\nAutoupdated table `Role`.');
        });
      });
    });
  });

  db.autoupdate('AccessToken', function(err) {
    if (err) throw err;
    console.log('\nAutoupdated table `AccessToken`.');
  });

};

// ACL principalId
// User hasMany accessTokens
// Role hasMany RoleMapping
// AccessToken belongsTo User
// RoleMapping belongsTo Role
